﻿Public Class Rcliente

    Public Shared Function SeleccionarTodo(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of Ecliente)
        Dim clientes As List(Of Ecliente) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                clientes = Dcliente.SeleccionarTodo(descEmpresa)
                If clientes Is Nothing Then clientes = New List(Of Ecliente)
                If DisplaySelect Then clientes.Insert(0, New Ecliente("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return clientes
    End Function
    Public Shared Function SeleccionarClienteCoopropietario(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal idRelacion As Int32) As List(Of Ecliente)
        Dim cliCoopropietario As List(Of Ecliente) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                cliCoopropietario = Dcliente.SeleccionarClienteCoopropietario(descEmpresa, idRelacion)
                If cliCoopropietario Is Nothing Then cliCoopropietario = New List(Of Ecliente)
                'If DisplaySelect Then cliConyCoops.Insert(0, New EcliConyCoop("00", "-- SELECIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return cliCoopropietario
    End Function
    Public Shared Function filtrarCoopropietario(ByVal descEmpresa As String, ByVal idProyecto As Int32, ByVal idEtapa As Int32, ByVal idSeparacion As Int32) As List(Of Ecliente)
        Dim cliCoopropietario As List(Of Ecliente) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                cliCoopropietario = Dcliente.filtrarCoopropietario(descEmpresa, idProyecto, idEtapa, idSeparacion)
                If cliCoopropietario Is Nothing Then cliCoopropietario = New List(Of Ecliente)
                'If DisplaySelect Then cliConyCoops.Insert(0, New EcliConyCoop("00", "-- SELECIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return cliCoopropietario
    End Function
    Public Shared Function filtrarCoopropietarioTemp(ByVal descEmpresa As String, ByVal idProyecto As Int32, ByVal idEtapa As Int32, ByVal idSeparacion As Int32) As List(Of Ecliente)
        Dim cliCoopropietario As List(Of Ecliente) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                cliCoopropietario = Dcliente.filtrarCoopropietarioTemp(descEmpresa, idProyecto, idEtapa, idSeparacion)
                If cliCoopropietario Is Nothing Then cliCoopropietario = New List(Of Ecliente)
                'If DisplaySelect Then cliConyCoops.Insert(0, New EcliConyCoop("00", "-- SELECIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return cliCoopropietario
    End Function
    Public Shared Function filtrarRepresentante(ByVal descEmpresa As String, ByVal idProyecto As Int32, ByVal idEtapa As Int32, ByVal idSeparacion As Int32) As List(Of Ecliente)
        Dim cliRepresentante As List(Of Ecliente) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                cliRepresentante = Dcliente.filtrarRepresentante(descEmpresa, idProyecto, idEtapa, idSeparacion)
                If cliRepresentante Is Nothing Then cliRepresentante = New List(Of Ecliente)
                'If DisplaySelect Then cliConyCoops.Insert(0, New EcliConyCoop("00", "-- SELECIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return cliRepresentante
    End Function
    Public Shared Function filtrarRepresentanteTemp(ByVal descEmpresa As String, ByVal idProyecto As Int32, ByVal idEtapa As Int32, ByVal idSeparacion As Int32) As List(Of Ecliente)
        Dim cliRepresentante As List(Of Ecliente) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                cliRepresentante = Dcliente.filtrarRepresentanteTemp(descEmpresa, idProyecto, idEtapa, idSeparacion)
                If cliRepresentante Is Nothing Then cliRepresentante = New List(Of Ecliente)
                'If DisplaySelect Then cliConyCoops.Insert(0, New EcliConyCoop("00", "-- SELECIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return cliRepresentante
    End Function
    Public Shared Function filtrarConyugue(ByVal descEmpresa As String, ByVal idProyecto As Int32, ByVal idEtapa As Int32, ByVal idSeparacion As Int32) As Ecliente
        Dim cliConyugue As Ecliente = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                cliConyugue = Dcliente.filtrarConyugue(descEmpresa, idProyecto, idEtapa, idSeparacion)
                If cliConyugue Is Nothing Then cliConyugue = New Ecliente
                'If DisplaySelect Then cliConyCoops.Insert(0, New EcliConyCoop("00", "-- SELECIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return cliConyugue
    End Function
    Public Shared Function SeleccionarFiltraNombreApePaternoApeMaterno(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal filtro As String) As List(Of Ecliente)
        Dim clientes As List(Of Ecliente) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                clientes = Dcliente.SeleccionarFiltraNombreApePaternoApeMaterno(descEmpresa, filtro)
                If clientes Is Nothing Then clientes = New List(Of Ecliente)
                If DisplaySelect Then clientes.Insert(0, New Ecliente("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return clientes
    End Function
    Public Shared Function SeleccionarFiltroAtencionClientexNombreApePaternoApeMaterno _
    (ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal filtro As String, ByVal pVendedor As Evendedor) As List(Of Ecliente)
        Dim atencionClientes As List(Of Ecliente) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                atencionClientes = Dcliente.SeleccionarFiltroAtencionClientexNombreApePaternoApeMaterno(descEmpresa, filtro, pVendedor)
                If atencionClientes Is Nothing Then atencionClientes = New List(Of Ecliente)
                If DisplaySelect Then atencionClientes.Insert(0, New Ecliente("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return atencionClientes
    End Function
    Public Shared Function SeleccionarFiltroAtencionClientexNombreApePaternoApeMaternoDNI _
(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal filtro As String, ByVal pVendedor As Evendedor, ByVal DNI As String) As List(Of Ecliente)
        Dim atencionClientes As List(Of Ecliente) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                atencionClientes = Dcliente.SeleccionarFiltroAtencionClientexNombreApePaternoApeMaternoDNI(descEmpresa, filtro, pVendedor, DNI)
                If atencionClientes Is Nothing Then atencionClientes = New List(Of Ecliente)
                If DisplaySelect Then atencionClientes.Insert(0, New Ecliente("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return atencionClientes
    End Function
    Public Shared Function SeleccionarFiltroAtencionClientexNombreApePaternoApeMaterno _
    (ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal pProformaCabecera As EproformaCabecera) As List(Of Ecliente)
        Dim atencionClientes As List(Of Ecliente) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                atencionClientes = Dcliente.SeleccionarFiltroAtencionClientexNombreApePaternoApeMaterno(descEmpresa, pProformaCabecera)
                If atencionClientes Is Nothing Then atencionClientes = New List(Of Ecliente)
                If DisplaySelect Then atencionClientes.Insert(0, New Ecliente("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return atencionClientes
    End Function
    Public Shared Function SeleccionarFiltroAhorroPrevioClientexNombreApePaternoApeMaterno _
    (ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal filtro As String) As List(Of Ecliente)
        Dim atencionClientes As List(Of Ecliente) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                atencionClientes = Dcliente.SeleccionarFiltroAhorroPrevioClientexNombreApePaternoApeMaterno(descEmpresa, filtro)
                If atencionClientes Is Nothing Then atencionClientes = New List(Of Ecliente)
                If DisplaySelect Then atencionClientes.Insert(0, New Ecliente("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return atencionClientes
    End Function

    Public Shared Function SeleccionarTodoMantedor(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal Proyecto As Int32) As List(Of Ecliente)
        Dim clientes As List(Of Ecliente) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                clientes = Dcliente.SeleccionarTodoMantedor(descEmpresa, Proyecto)
                If clientes Is Nothing Then clientes = New List(Of Ecliente)
                If DisplaySelect Then clientes.Insert(0, New Ecliente("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return clientes
    End Function
    Public Shared Function BuscarMantedor(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal pCliente As Ecliente, ByVal Proyecto As Int32) As List(Of Ecliente)
        Dim clientes As List(Of Ecliente) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                clientes = Dcliente.BuscarMantedor(descEmpresa, pCliente, Proyecto)
                If clientes Is Nothing Then clientes = New List(Of Ecliente)
                If DisplaySelect Then clientes.Insert(0, New Ecliente("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return clientes
    End Function
    Public Shared Function SelClienteConAdicionales(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal filtro As String) As List(Of Ecliente)
        Dim clienteAdicionales As List(Of Ecliente) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                clienteAdicionales = Dcliente.SelClienteConAdicionales(descEmpresa, filtro)
                If clienteAdicionales Is Nothing Then clienteAdicionales = New List(Of Ecliente)
                If DisplaySelect Then clienteAdicionales.Insert(0, New Ecliente("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using
        Return clienteAdicionales
    End Function

    Public Shared Function Añadir(ByVal descEmpresa As String, ByVal pCliente As Ecliente, ByRef idCliente As Integer) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dcliente.Añadir(descEmpresa, pCliente, idCliente)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function AñadirCoopropietario(ByVal descEmpresa As String, ByVal pCoopropietario As Ecliente, ByRef idCoopropietario As Integer, ByVal idCliente As Int32) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dcliente.AñadirCoopropietario(descEmpresa, pCoopropietario, idCoopropietario, idCliente)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function AñadirCoopropietarioTemp(ByVal descEmpresa As String, ByVal pCoopropietario As Ecliente, ByRef idCoopropietario As Integer, ByVal idCliente As Int32) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dcliente.AñadirCoopropietarioTemp(descEmpresa, pCoopropietario, idCoopropietario, idCliente)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function AñadirRepresentante(ByVal descEmpresa As String, ByVal pRepresentante As Ecliente, ByRef idRepresentante As Integer, ByVal idCliente As Int32) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dcliente.AñadirRepresentante(descEmpresa, pRepresentante, idRepresentante, idCliente)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function AñadirRepresentanteTemp(ByVal descEmpresa As String, ByVal pRepresentante As Ecliente, ByRef idRepresentante As Integer, ByVal idCliente As Int32) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dcliente.AñadirRepresentanteTemp(descEmpresa, pRepresentante, idRepresentante, idCliente)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function AñadirClienteMantenedor(ByVal descEmpresa As String, ByVal pCliente As Ecliente, ByRef idCliente As Integer) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dcliente.AñadirClienteMantenedor(descEmpresa, pCliente, idCliente)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function AñadirConyugue(ByVal descEmpresa As String, ByVal pConyugue As Ecliente, ByRef idConyugue As Integer, ByVal idCliente As Int32) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dcliente.AñadirConyugue(descEmpresa, pConyugue, idConyugue, idCliente)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function AñadirConyugueMantenedor(ByVal descEmpresa As String, ByVal pConyugue As Ecliente, ByRef idConyugue As Integer, ByVal idCliente As Int32) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dcliente.AñadirConyugueMantenedor(descEmpresa, pConyugue, idConyugue, idCliente)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function AñadirApoderado(ByVal descEmpresa As String, ByVal pApoderado As Ecliente, ByRef idApoderado As Integer, ByVal idCliente As Int32) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dcliente.AñadirApoderado(descEmpresa, pApoderado, idApoderado, idCliente)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

    Public Shared Function AñadirTemporal(ByVal descEmpresa As String, ByVal pCliente As Ecliente, ByRef idCliente As Integer) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dcliente.AñadirTemporal(descEmpresa, pCliente, idCliente)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function AñadirClienteMantenedorTemporal(ByVal descEmpresa As String, ByVal pCliente As Ecliente, ByRef idCliente As Integer) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dcliente.AñadirClienteMantenedorTemporal(descEmpresa, pCliente, idCliente)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function AñadirConyugueTemporal(ByVal descEmpresa As String, ByVal pConyugue As Ecliente, ByRef idConyugue As Integer, ByVal idCliente As Int32) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dcliente.AñadirConyugueTemporal(descEmpresa, pConyugue, idConyugue, idCliente)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function AñadirConyugueMantenedorTemporal(ByVal descEmpresa As String, ByVal pConyugue As Ecliente, ByRef idConyugue As Integer, ByVal idCliente As Int32) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dcliente.AñadirConyugueMantenedorTemporal(descEmpresa, pConyugue, idConyugue, idCliente)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function AñadirApoderadoTemporal(ByVal descEmpresa As String, ByVal pApoderado As Ecliente, ByRef idApoderado As Integer, ByVal idCliente As Int32) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dcliente.AñadirApoderadoTemporal(descEmpresa, pApoderado, idApoderado, idCliente)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

    Public Shared Function Editar(ByVal descEmpresa As String, ByVal cliente As Ecliente) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dcliente.Editar(descEmpresa, cliente)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

    Public Shared Function EditarClienteMantenedor(ByVal descEmpresa As String, ByVal pCliente As Ecliente) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dcliente.EditarClienteMantenedor(descEmpresa, pCliente)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function EditarConyugueMantenedor(ByVal descEmpresa As String, ByVal pConyugue As Ecliente) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dcliente.EditarConyugueMantenedor(descEmpresa, pConyugue)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function EditarApoderadoMantenedor(ByVal descEmpresa As String, ByVal pApoderado As Ecliente) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dcliente.EditarApoderadoMantenedor(descEmpresa, pApoderado)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

    Public Shared Function Eliminar(ByVal descEmpresa As String, ByVal cliente As Ecliente) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dcliente.Eliminar(descEmpresa, cliente)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function EliminarMantenedor(ByVal descEmpresa As String, ByVal pCliente As Ecliente) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Dcliente.EliminarMantenedor(descEmpresa, pCliente)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

    Public Shared Function SeleccionarApoderado(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal idProyecto As Int32, ByVal idEtapa As Int32, ByVal idSeparacionVenta As Int32) As List(Of Ecliente)
        Dim clientes As List(Of Ecliente) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                clientes = Dcliente.SeleccionarApoderado(descEmpresa, idProyecto, idEtapa, idSeparacionVenta)
                If clientes Is Nothing Then clientes = New List(Of Ecliente)
                'If DisplaySelect Then clientes.Insert(0, New Ecliente("00", "-- SELECIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return clientes
    End Function

    Public Shared Function SeleccionarTodoXId(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal idCliente As Int32) As List(Of Ecliente)
        Dim clientes As List(Of Ecliente) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                clientes = Dcliente.SeleccionarTodoXId(descEmpresa, idCliente)
                If clientes Is Nothing Then clientes = New List(Of Ecliente)
                If DisplaySelect Then clientes.Insert(0, New Ecliente("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return clientes
    End Function

End Class
